<template>
	<view class="container">
		<template v-if="isFixSearch">
			<view class="home-headers" @tap="navTo('/packageA/pages/productList/productList?selectedIndex=0')">
				<view class="home-search">
					<view class="iconfont iconsousuohome"></view>
					<view class="home-search-text">搜索商品名称</view>
				</view>
			</view>
		</template>
		<view :class="[isFixSearch?'main-component':'']">
			<view v-for="(item,index) in dragList" :key="index">
				<base-component :record="item" :isSearch="isSearch"></base-component>
			</view>
		</view>
		<tui-modal></tui-modal>
	</view>
</template>

<script>
	import baseComponent from '@/components/baseComponent/baseComponent'
	export default {
		data() {
			return {
				dragList: [],
				isSearch: false,
			}
		},
		components: {
			baseComponent,
		},
		onLoad(options){
			console.log(options);
			this.getActivityJson(options.id);
			// #ifdef H5
			   this.$wechat.noShare();
			// #endif
		},
		methods: {
			getActivityJson(id){
				this.$http.getActivityJson(id).then((res) => {
					if(res.status === 0) {
						if(res.data) {
							uni.setNavigationBarTitle({
								title: `${res.data.pageName}`
							});
							// this.dragList = JSON.parse(res.data.data).list;
							const data = [...JSON.parse(res.data.data).list]
							console.log(this.dragList)
							if(JSON.parse(res.data.data).list[0].type == 'search') {
								this.isSearch = true;
								this.dragList = data.filter((i,k) => k != 0);
							} else {
								this.dragList = data;
								this.isSearch = false;
							}
							console.log(this.isSearch)
						}
					}
				})
			},
		},
	}
</script>

<style lang="scss">
	.container {
		background-color: #fff;
		height: 100vh;
		.main-component {
			padding-top: 100rpx;
			overflow-y: auto;
			max-height: 92vh;
		}
		
		.home-headers {
			width: 100%;
			height: 100rpx;
			padding: 0 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #fff;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 999;
		}
		
		.home-search {
			width: 100%;
			height: 60rpx;
			padding: 0 20rpx;
			box-sizing: border-box;
			background: #fff;
			display: flex;
			align-items: center;
			flex-wrap: nowrap;
			color: #999;
			border-radius: 50rpx;
			border: 1px solid #ED716A;
		
			.home-search-text {
				font-size: 26rpx;
				color: #CCCCCCFF;
			}
		}
	}
</style>
